define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'xiluedu/vip_order/index' + location.search,
                    add_url: 'xiluedu/vip_order/add',
                    edit_url: 'xiluedu/vip_order/edit',
                    del_url: 'xiluedu/vip_order/del',
                    multi_url: 'xiluedu/vip_order/multi',
                    table: 'xiluedu_vip_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'platform', title: __('Platform'), operate: 'LIKE'},
                        {field: 'user.nickname', title: __('User_id'), operate: 'LIKE'},
                        {field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
                        //{field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
                        {field: 'pay_price', title: __('Pay_price'), operate:false},
                        {field: 'pay_type', title: __('Pay_type'), searchList: {"0":__('Pay_type 0'),"1":__('Pay_type 1')}, formatter: Table.api.formatter.status},
                        {field: 'pay_status', title: __('Pay_status'), searchList: {"0":__('Pay_status 0'),"1":__('Pay_status 1')}, formatter: Table.api.formatter.status},
                        {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'vip_name', title: __('Vip_name'), operate: 'LIKE'},
                        {field: 'vip_salesprice', title: __('Vip_salesprice'), operate:false},
                        {field: 'vip_expire', title: __('Vip_expire'),operate:false},
                        {field: 'vip_unit', title: __('Vip_unit'), searchList: {"1":__('Vip_unit 1'),"2":__('Vip_unit 2'),"3":__('Vip_unit 3')}, formatter: Table.api.formatter.normal},
                        {field: 'ip', title: __('Ip'), operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        //{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
